/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.sdgakj.repository;

import com.sdgakj.entity.Family;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface FamilyDao extends PagingAndSortingRepository<Family, Long>,JpaSpecificationExecutor<Family> {

    /**
     * 根据用户id获取家族
     * @param id
     * @return
     */
    @Query("from Family where user_id=?1")
    List<Family> getFamilyByUserId(Long id);

   /* @Query("select * from f_family where fu_id=:fuid")
    Page<Family> findFamilyByUserId(@Param("fuid") Long fuid,Specification<Family> spec, PageRequest pageRequest );*/

    @Query(value = "select count(1) from f_family",nativeQuery = true)
    Long getFamilyCount();
}
